import Tools from 'tools/index';
import apiConfig from "./../apiConfig";
export default {
    // 选择地址
    async SelectAddress(params_) {
        if (!this.isError(params_)) return
        // 打开加载遮罩层
        Tools.setLoad(true);
        let _d = await import("./index.js");

        if (params_.selected == undefined) {
            params_.selected = {
                // 省
                province: '',
                provinceCode: '',

                // 市
                city: '',
                cityCode: '',

                // 区
                region: '',
                regionCode: '',

                // 街
                street: '',
                streetCode: ''
            }
        }
        // 精确级别 默认到街道 四级联动
        if (params_.level == undefined) {
            params_.level = "street"
        }
        
        // 关闭加载遮罩层
        Tools.setLoad(false);
        _d.default.init({
            appWindow: params_.appWindow,
            selected: params_.selected,
            level: params_.level,
            apiConfig: this.setConfig(params_.apiConfig, apiConfig),
            onSuccess: (r) => {
                params_.onSuccess(r)
            },
        })
    },
}